package com.yuyu.shop.api.controller.order.seckill;

import com.yuyu.commons.annotation.AccessLimit;
import com.yuyu.shop.api.apimodel.order.dto.SecKillReq;
import com.yuyu.shop.domain.order.DO.OrderDO;
import com.yuyu.shop.domain.order.service.SecKillService;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author
 * @version 1.0
 * @description :秒杀相关
 * @date 2022/9/23 10:36
 */
@AllArgsConstructor(onConstructor = @_(@Autowired))
@RestController
@RequestMapping("/secKill")
public class SecKillOrderController {

    private final SecKillService secKillService;

    @ApiOperation("secKill description")
    @PostMapping("/create")
    @AccessLimit(limit = 1,second = 1)
    public void secKill( @RequestBody SecKillReq req){
        secKillService.secKill(req);
    }

    @ApiOperation("查询秒杀订单")
    @PostMapping("/query")
    @AccessLimit()
    public OrderDO query(@RequestParam("goodId")Long goodId){
      return new OrderDO().querySecKillOrder(goodId);
    }

}
